package com.ewanghuiju.app.widget.popupwindow;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.ewanghuiju.app.R;
import com.ewanghuiju.app.util.nodoubleclick.AntiShake;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import razerdp.basepopup.BasePopupWindow;

/**
 * @author sj  qq:751943509
 * @class 拍照和选择照片弹框
 * @time 2020/2/19
 */
public class PicSelectedPopup extends BasePopupWindow {


    @BindView(R.id.picture_tv_photo)
    TextView pictureTvPhoto;
    @BindView(R.id.picture_tv_video)
    TextView pictureTvVideo;
    private PicSelectedPopupCallback picSelectedPopupCallback;

    public PicSelectedPopup(Context context, PicSelectedPopupCallback picSelectedPopupCallback) {
        super(context);
        setWidth(getScreenWidth());
        ButterKnife.bind(this, getContentView());
        this.picSelectedPopupCallback = picSelectedPopupCallback;
        pictureTvVideo.setText("相册");
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.picture_dialog_camera_selected);
    }

    @OnClick({R.id.picture_tv_photo, R.id.picture_tv_video, R.id.picture_tv_cancel})
    public void doClick(View view) {
        if (AntiShake.check(view.getId())) {
            return;
        }
        switch (view.getId()) {
            case R.id.picture_tv_photo:
                //拍照
                dismiss();
                if (picSelectedPopupCallback != null) {
                    picSelectedPopupCallback.cameraClickCallback();
                }
                break;
            case R.id.picture_tv_video:
                //相册
                dismiss();
                if (picSelectedPopupCallback != null) {
                    picSelectedPopupCallback.albumClickCallback();
                }
                break;
            case R.id.picture_tv_cancel:
                //确定按钮
                dismiss();
                break;
            default:
                break;
        }
    }

    public interface PicSelectedPopupCallback {

        void cameraClickCallback();

        void albumClickCallback();
    }
}
